//笔试强训:字母搜集

#include <iostream>
#include <vector>
#include <string>
using namespace std;

int score(char c)
{
    switch(c)
    {
        case 'l': return 4;
        case 'o': return 3;
        case 'v': return 2;
        case 'e': return 1;
    }
    return 0;
}

int main() {
    int n, m; cin >> n >> m;
    vector<string> v(n);
    vector<vector<int>> dp(n, vector<int>(m, 0));
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
    }

    dp[0][0] = score(v[0][0]);
    for(int i = 1; i < n; i++)
        dp[i][0] = score(v[i][0]) + dp[i - 1][0];
    for(int j = 1; j < m; j++)
        dp[0][j] = score(v[0][j]) + dp[0][j - 1];
    
    for(int i = 1; i < n; i++)
    {
        for(int j = 0; j < m; j++)
            dp[i][j] = score(v[i][j]) + max(dp[i - 1][j], dp[i][j - 1]);
    }
    cout << dp[n - 1][m - 1] << endl;
}